package org.bbd.cumi.page;

import java.text.DecimalFormat;
import java.text.NumberFormat;

import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.record.PropertyChangeObserver;
import org.bbd.cumi.facade.AccessFacade;
import org.bbd.cumi.util.SpringUtil;

public class BaseCumiPage extends BasePage {

	
	private static NumberFormat format=new DecimalFormat("###,###,###,##0");
	
	public String getClientId() {
	
		return null;
	}
	
	public AccessFacade getAccessFacade()
	{
		return (AccessFacade)SpringUtil.getBean("accessFacade");
	}

	@Override
	public void setClientId(String arg0) {
	
	}

	@Override
	public PropertyChangeObserver getPropertyChangeObserver() {
		return null;
	}

	public String formatByte(long value)
	{
		if(value<1024)
			return value + " b";
		return format.format(value/1024) + " KB";
	}
	
	public String formatNumber(long value)
	{
		return format.format(value);
	}
	public String formatTime(long value)
	{
		return String.valueOf(value);
//		StringBuilder str=new StringBuilder();
//		long ms=value % 1000;
//		value=(value-ms)/1000;
//		long sec=value % 60;
//		value=(value-sec)/60;
//		long min=value%60;
//		value=(value-min)/60;
//		long hrs=value%60;
//		if(hrs>0)
//			str.append(hrs).append(" h");
//		if(min>0)
//			str.append(min).append(" m");
//		str.append(sec).append(".");		
	}
}
